﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Decortator
{


    public interface IYeshi
    {
        void Yeshi();
    }

    public interface IXiaoyin
    {
        void Xiaoyin();
    }

    public interface  IFlay
    {
        void Flay();
    }

    public abstract class Tank
    {
        public abstract void Shot();
        public abstract void Run();
    }

    public class T50 : Tank
    {
        public override void Run()
        {
            Console.WriteLine("T50 Run");
        }

        public override void Shot()
        {
            Console.WriteLine("T50 Shot");
        }
    }

    public class T60 : Tank
    {
        public override void Run()
        {
            Console.WriteLine("T60 Run");
        }

        public override void Shot()
        {
            Console.WriteLine("T60 Shot");
        }
    }

    /// <summary>
    /// 修饰类
    /// </summary>
    public abstract class Decortator : Tank
    {
        private Tank tank;

        public Decortator(Tank  tt)
        {
            this.tank = tt;
        }
        public override void Run()
        {
            tank.Run();
        }

        public override void Shot()
        {
            tank.Shot();
        }
    }

    public class DecortYeshi : Decortator
    {
        private IYeshi entity;
        public DecortYeshi(Tank tt, IYeshi yeshi) : base(tt)
        {
            this.entity = yeshi;
        }
        public override void Run()
        {
            this.entity.Yeshi();
            base.Run();
        }

        public override void Shot()
        {
            entity.Yeshi();
            base.Shot();
        }
    }

    public class DecortXiaoyin : Decortator
    {
        private IXiaoyin entity;
        public DecortXiaoyin(Tank tt, IXiaoyin ent) : base(tt)
        {
            this.entity = ent;
        }

        public override void Run()
        {
            entity.Xiaoyin();
            base.Run();
        }

    }

    public class DectorFlay : Decortator
    {
        IFlay entity;
        public DectorFlay(Tank tt, IFlay entity) : base(tt)
        {
            this.entity = entity;
        }

        public override void Run()
        {
            entity.Flay();
            base.Run();
        }
    }

    public class YeshiClass : IYeshi
    {
        public void Yeshi()
        {
            Console.WriteLine(" 打开夜视功能！ ");
        }
    }

    public class XiaoyinClass : IXiaoyin
    {
        public void Xiaoyin()
        {
            Console.WriteLine("实现了消音功能！！1");
        }
    }
}
